import www.orm
import asyncio, aiomysql
from www.model import User, Blog, Comment


async def test(loop):
    await www.orm.create_pool(loop=loop, user='root', password='root', database='awesome')
    with (await www.orm.__pool) as conn:
        cur = await conn.cursor(aiomysql.DictCursor)
    sql = 'select id from user'
    await cur.execute(sql)
    rs = await cur.fetchall()
    print(rs)
    u = User(name='Test', password='1234', image='about:blank')
    await u.save()


loop = asyncio.get_event_loop()
loop.run_until_complete(test(loop))
loop.run_forever()
#for x in test():
#    pass